<?php

/**
 * 个人订单管理
 * 
 * @author 叶风
 * Qq:    355007778
 * Email: ye.fn@163.com
 */

namespace c\shop\order;
\YF_f::initC('\c\auth\permission')->login();

class p extends b
{
    var $dispLayout = 'user';
    
    function index_home()
    {
        $w = 'AND t1.user_id='. \YF_f::$login_user_id;
        $this->_home($w);
    }
    function index_del()
    {
        $w = ' AND t1.user_id='.\YF_f::$login_user_id . ' AND state IN(0,1)';
        $this->_del($w);
    }
    function index_view()
    {
        $ord = $this->db->getOne($this->table, '*', 'id='. intval($_GET['id']));
        if ($ord['user_id']!=\YF_f::$login_user_id)
            $this->clue(\lang::g('Over'));
        $this->_view($ord);
        
        $this->display('main');
    }
    //收货
    function index_takeGoods()
    {
        $id = intval($_GET['id']);
        
        if ($this->complete($id))
         {
            $this->flow($id, \lang::g('Take goods.'));
            ajax_json(TRUE);
         }
        else
            ajax_json(\lang::g('save fail'));
    }
    //退货
    function index_bGoods()
    {
        $id = intval($_GET['id']);
        $this->db->save($this->table, array('state'=>11), 'id='. $id. ' AND state IN(2,3)');
        if ($this->db->num_affected()>0)
         {
            $this->flow($id, \lang::g('Request return goods.'));
            ajax_json(\lang::g('OK'));
         }
        else
            ajax_json(\lang::g('save fail'));
    }
}
